<?php
require_once('lib/db_connection.php');

$query_cargo = "SELECT dts_veh_tbl.veh_num as plate, queue_tbl.trip_no as trip FROM queue_tbl JOIN dts_veh_tbl ON queue_tbl.plate_id=dts_veh_tbl.vehicle_id WHERE dts_veh_tbl.style_name='cargo' AND queue_tbl.status='intransit' AND (queue_tbl.return_to_plant<'".date('Y-m-d')."' OR (queue_tbl.return_to_plant='".date('Y-m-d')."' AND queue_tbl.return_to_plant_time<'".date('H:i')."'))";
$result_cargo = mysql_query($query_cargo) or die("SELECT CARGO ".mysql_error());

$query_trailer = "SELECT dts_veh_tbl.veh_num as plate, queue_tbl.trip_no as trip FROM queue_tbl JOIN dts_veh_tbl ON queue_tbl.plate_id=dts_veh_tbl.vehicle_id WHERE dts_veh_tbl.style_name='trailer' AND queue_tbl.status='intransit' AND (queue_tbl.return_to_plant<'".date('Y-m-d')."' OR (queue_tbl.return_to_plant='".date('Y-m-d')."' AND queue_tbl.return_to_plant_time<'".date('H:i')."'))";
$result_trailer = mysql_query($query_trailer) or die("SELECT TRAILER ".mysql_error());

$query_bulk = "SELECT dts_veh_tbl.veh_num as plate, queue_tbl.trip_no as trip FROM queue_tbl JOIN dts_veh_tbl ON queue_tbl.plate_id=dts_veh_tbl.vehicle_id WHERE dts_veh_tbl.style_name='bulk' AND queue_tbl.status='intransit' AND (queue_tbl.return_to_plant<'".date('Y-m-d')."' OR (queue_tbl.return_to_plant='".date('Y-m-d')."' AND queue_tbl.return_to_plant_time<'".date('H:i')."'))";
$result_bulk = mysql_query($query_bulk) or die("SELECT BULK ".mysql_error());
?>
<html>
<head>
</head>
<body>


<p style='color:white;font-size:12px;' id='tot_cargo'></p>
<hr />
<table border='1' style='width:100%;margin-left:0%;margin-right:0%;'>
<tr>
  <th style='width:65%;color:white;'>PLATE</th>
  <th style='width:35%;color:white;'>TRIP&#35;</th>
</tr>
<?php
$tot_cargo = 0;
while($row_cargo = mysql_fetch_array($result_cargo))
{
?>
<tr>
	<td style='font-size:12px;width:50px;color:white;'>&nbsp;<?php echo $row_cargo['plate']?>&nbsp;</td>
	<td style='font-size:12px;width:50px;color:white;'>&nbsp;<?php echo $row_cargo['trip']?>&nbsp;</td>
</tr>
<?php
$tot_cargo ++;
}
echo "<script type='text/javascript'>
document.getElementById('tot_cargo').innerHTML = 'CARGO: '+'".$tot_cargo."';
</script>";
?>
</table>






<p style='color:white;font-size:12px;' id='tot_trailer'></p>
<hr />
<table border='1' style='width:100%;margin-left:0%;margin-right:0%;'>
<tr>
  <th style='width:65%;color:white;'>PLATE</th>
  <th style='width:35%;color:white;'>TRIP&#35;</th>
</tr>
<?php
$tot_trailer = 0;
while($row_trailer = mysql_fetch_array($result_trailer))
{
?>
<tr>
	<td style='font-size:12px;width:50px;color:white;'>&nbsp;<?php echo $row_trailer['plate']?>&nbsp;</td>
	<td style='font-size:12px;width:50px;color:white;'>&nbsp;<?php echo $row_trailer['trip']?>&nbsp;</td>
</tr>
<?php
$tot_trailer ++;
}
echo "<script type='text/javascript'>
document.getElementById('tot_trailer').innerHTML = 'TRAILER: '+'".$tot_trailer."';
</script>";
?>
</table>






<p style='color:white;font-size:12px;' id='tot_bulk'></p>
<hr />
<table border='1' style='width:100%;margin-left:0%;margin-right:0%;'>
<tr>
  <th style='width:65%;color:white;'>PLATE</th>
  <th style='width:35%;color:white;'>TRIP&#35;</th>
</tr>
<?php
$tot_bulk = 0;
while($row_bulk = mysql_fetch_array($result_bulk))
{
?>
<tr>
	<td style='font-size:12px;width:50px;color:white;'>&nbsp;<?php echo $row_bulk['plate']?>&nbsp;</td>
	<td style='font-size:12px;width:50px;color:white;'>&nbsp;<?php echo $row_bulk['trip']?>&nbsp;</td>
</tr>
<?php
$tot_bulk ++;
}
echo "<script type='text/javascript'>
document.getElementById('tot_bulk').innerHTML = 'BULK: '+'".$tot_bulk."';
</script>";
?>
</table>
</body>
</html>